package com.laicunba.service;

import java.math.BigDecimal;
import java.util.List;

import com.laicunba.pojo.AccountDO;

public interface AccountService extends BaseService {
	/**
	 * 充值方式
	 */
	enum RECHARGE_WAY {
		ALIPAY, WEIXIN;
	}

	/**
	 * 会计科目
	 *
	 */
	enum ACCOUNTING_SUBJECT {
		// 用户级别(资产A)
		USER_CURRENCY_ALIPAY("A", "USER_CURRENCY_ALIPAY", "(用户)其它货币资金-支付宝"), //
		USER_CURRENCY_WEIXIN("A", "USER_CURRENCY_WEIXIN", "(用户)其它货币资金-微信"), //
		USER_CURRENCY_OFFLINE("A", "USER_CURRENCY_OFFLINE", "(用户)其它货币资金-线下付"), // 线下付资金线下管理,线上只作标记
		USER_CURRENCY_FUIOU("A", "USER_CURRENCY_FUIOU", "(用户)其它货币资金-富友"), //
		USER_CURRENCY_TYJ("A", "USER_CURRENCY_TYJ", "(用户)其它货币资金-体验金"), //
		// 用户级别(负债L)
		USER_BALANCE("L", "USER_BALANCE", "(用户)预收账款"), //
		USER_FINANCING_TARGET_BID("L", "USER_FINANCING_TARGET_BID", "(用户)融资"), //
		// 总账(资产A)
		CURRENCY_ALIPAY("A", "CURRENCY_ALIPAY", "其它货币资金-支付宝"), //
		CURRENCY_WEIXIN("A", "CURRENCY_WEIXIN", "其它货币资金-微信"), //
		CURRENCY_OFFLINE("A", "CURRENCY_OFFLINE", "其它货币资金-线下付"), //
		CURRENCY_FUIOU("A", "CURRENCY_FUIOU", "其它货币资金-富友"), //
		CURRENCY_TYJ("A", "CURRENCY_TYJ", "其它货币资金-体验金"), //
		// 总账(负债L)
		BALANCE("L", "BALANCE", "预收账款"), //
		FINANCING_TARGET_BID("L", "FINANCING_TARGET_BID", "融资"), //
		test("A", "", "");
		private String type;
		private String code;
		private String name;

		private ACCOUNTING_SUBJECT(String type, String code, String name) {
			this.type = type;
			this.code = code;
			this.name = name;
		}

		public String getName() {
			return name;
		}

		public String getCode() {
			return code;
		}

		/**
		 * 借?
		 */
		public boolean isAssets() {
			return "A".equals(type);
		}

		/**
		 * 贷?
		 */
		public boolean isLiability() {
			return "L".equals(type);
		}
	}

	List<AccountDO> listPlatformAccounts();

	/**
	 * 总余额,返回0时代表正确
	 * 
	 * @return
	 */
	BigDecimal totalBalance();

	boolean addBalance(String id, BigDecimal amt, BigDecimal oldBalance, long oldRowNum);

	boolean subtractBalance(String id, BigDecimal amt, BigDecimal oldBalance, long oldRowNum);

}
